[docs] Fix non-public entry docs. Various improvements to PTB docs.#25913
[docs] Fix non-public entry docs. Various improvements to PTB docs.#25913tnowacki merged 9 commits intoMystenLabs:mainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
docs/content/guides/developer/transactions/ptbs/prog-txn-blocks.mdx
Outdated
Show resolved
Hide resolved
| Move calls cannot return references (`&T` or `&mut T`). However, this restriction will be lifted in the future. | ||
|
|
||
| **Private generics:** | ||
| Some framework functions have type parameters that can only be instantiated with types defined in the same module. Since PTBs are not modules, they cannot supply these types and therefore cannot call these functions directly. For example, certain `sui::transfer` functions like `transfer` and `share_object` require a type defined in the calling module, and as such cannot be called from a PTB. Instead, use the `public_transfer` and `public_share_object` variants. |
There was a problem hiding this comment.
Sorry if I am being too picky here, but this suggests that public_transfer and public_share_object will always exist. I realize that they should exist if module developers intended transferring/sharing objects declared in the module but perhaps we could make it more explicit. Maybe finish with something like "Instead, use the public_transfer and public_share_object variants. These should be provided by the module developer."
There was a problem hiding this comment.
These are functions in sui::transfer
There was a problem hiding this comment.
Aaah, the ones to transfer/share objects with store. The whole thing is more of a nit anyway, but when reading it I thought we are talking objects that actually require module-defined transfer/share functions (and don't have store.
There was a problem hiding this comment.
Any thoughts on if I should reword this in any way to be more clear?
docs/content/guides/developer/transactions/ptbs/prog-txn-blocks.mdx
Outdated
Show resolved
Hide resolved
| **Publish:** | ||
|
|
||
| - Returns a single `sui::package::UpgradeCap`. | ||
| - After the package is staged, the runtime calls each module's `init` function (if present) in module order. `init` receives `&mut TxContext` and optionally a one-time witness. Additional `init` arguments are not yet supported but are planned. |
There was a problem hiding this comment.
It's not explicit what "module order" means here
|
|
||
| **Cliques** | ||
|
|
||
| The system tracks which values are entangled using _cliques_: |
There was a problem hiding this comment.
I feel like presented in this order, this will be difficult to digest. If possible, I would suggest the following order:
- describe intuition (even if it does not cover all the corner cases) behind the entry function rules (in particular, what behavior they try to prevent and which behavior they try to allow)
- give some code examples illustrating this
- provide a more formal description of the rules via hot cliques
There was a problem hiding this comment.
I'm not sure I have a more formal description, but I have tried to expand on the intuition section above and reiterate it here. There are examples in the following section.
docs/content/guides/developer/transactions/ptbs/inputs-and-results.mdx
Outdated
Show resolved
Hide resolved
docs/content/guides/developer/transactions/ptbs/prog-txn-blocks.mdx
Outdated
Show resolved
Hide resolved
docs/content/guides/developer/transactions/ptbs/prog-txn-blocks.mdx
Outdated
Show resolved
Hide resolved
docs/content/guides/developer/transactions/ptbs/prog-txn-blocks.mdx
Outdated
Show resolved
Hide resolved
docs/content/guides/developer/transactions/ptbs/prog-txn-blocks.mdx
Outdated
Show resolved
Hide resolved
docs/content/guides/developer/transactions/ptbs/prog-txn-blocks.mdx
Outdated
Show resolved
Hide resolved
docs/content/guides/developer/transactions/ptbs/prog-txn-blocks.mdx
Outdated
Show resolved
Hide resolved
docs/content/guides/developer/transactions/ptbs/prog-txn-blocks.mdx
Outdated
Show resolved
Hide resolved
docs/content/guides/developer/transactions/ptbs/prog-txn-blocks.mdx
Outdated
Show resolved
Hide resolved
Co-authored-by: Adam Welc <adam@mystenlabs.com> Co-authored-by: Jessie Mongeon <133128541+jessiemongeon1@users.noreply.github.com>
| - If you upgrade a package `P1` to `P2`, other packages and clients that depend on `P1` will continue using `P1`. They do not auto-update to `P2`. Both dependent packages and client code must be explicitly updated to point at `P2`. | ||
| - Packages that expect to be extended by dependent packages can avoid breaking their extensions with each upgrade by providing a standard (unchanging) interface that all versions conform to. See the [message sending](https://github.com/wormhole-foundation/wormhole/blob/74dea3bf22f0e27628b432c3e9eac05c85786a99/sui/wormhole/sources/publish_message.move) across a bridge example from Wormhole. Extension packages that produce outbound messages can use [`prepare_message`](https://github.com/wormhole-foundation/wormhole/blob/74dea3bf22f0e27628b432c3e9eac05c85786a99/sui/wormhole/sources/publish_message.move#L68-L90) from any version of the Wormhole package to produce a [`MessageTicket`](https://github.com/wormhole-foundation/wormhole/blob/74dea3bf22f0e27628b432c3e9eac05c85786a99/sui/wormhole/sources/publish_message.move#L52-L66) while client code that sends the message must pass that `MessageTicket` into [`publish_message`](https://github.com/wormhole-foundation/wormhole/blob/74dea3bf22f0e27628b432c3e9eac05c85786a99/sui/wormhole/sources/publish_message.move#L92-L152) in the latest version of the package. | ||
| - `public` function signatures cannot be deleted or changed, but `public(friend)` functions can. Use `public(friend)` or private visibility liberally unless you are exposing library functions that will live forever. | ||
| - `public` function signatures cannot be deleted or changed, but `public(package)` functions can. Use `public(package)` or private visibility liberally unless you are exposing library functions that will live forever. |
| In this invalid PTB, the `HotPotato` from command 0 is still alive in the same clique as `Input(0)` when `spend` is called: | ||
|
|
||
| ``` | ||
| // Invalid PTB |
There was a problem hiding this comment.
I think it would help visually if we used some syntax on these code blocks. Anything that would grey out comments and make commands stand out.
There was a problem hiding this comment.
I will mark them as Move?
docs/content/guides/developer/transactions/ptbs/inputs-and-results.mdx
Outdated
Show resolved
Hide resolved
damirka
left a comment
There was a problem hiding this comment.
LGTM overall with few nits
…ults.mdx Co-authored-by: Damir Shamanaev <damirka.ru@gmail.com>
docs/content/guides/developer/transactions/ptbs/prog-txn-blocks.mdx
Outdated
Show resolved
Hide resolved
| **`TxContext` handling:** | ||
| `TxContext` parameters (`&TxContext` or `&mut TxContext`) are automatically injected by the runtime; callers do not supply them. `TxContext` can appear at any position in the parameter list, and a function can have multiple `TxContext` parameters as long as they are immutable (`&TxContext`). These parameters are not counted toward the user-supplied argument count for indexing purposes. | ||
|
|
||
| #### Non-public entry function restrictions {#non-public-entry-function-restrictions} |
There was a problem hiding this comment.
#non-public-entry-function-restrictions will be the anchor for this heading by default, so you don't need to manually define it, just FYI.
…s.mdx Co-authored-by: Jessie Mongeon <133128541+jessiemongeon1@users.noreply.github.com>
Description
entryfunctions.Test plan
Release notes
Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required.
For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates.